<!-- 账号设置 -->
<template>
<div class="container">
    <div class="controlBox">
        <el-button type="primary" size="mini" @click="addAccount">新增</el-button>
        <el-button type="primary" size="mini">删除</el-button>
        <!-- @click='deletes' -->
        <el-button type="primary" size="mini">批量导出</el-button>
    </div>
    <!-- 搜索老人 -->
    <el-form ref="form" :inline="true" :model="search" label-width="80px" size="mini">
        <el-form-item label="搜索老人">
            <el-input v-model="search.id" placeholder="请输入关键词"></el-input>
        </el-form-item>
        <el-form-item>
            <el-button type="primary" @click="getDictListFun">搜 索</el-button>
        </el-form-item>
    </el-form>

    <!-- 新增账号  弹框 -->
    <el-dialog title="" :visible.sync="showAddPopup" width="40%" center>
        <div class="scrollBox">
            <el-form ref="addForm" :model="addForm" :rules="rules" label-position="left" label-width="100px">
                <el-form-item label="姓名：" prop="name">
                    <el-col :span="11">
                        <el-input v-model="addForm.name" />
                    </el-col>
                </el-form-item>
                <el-form-item label="性别：" prop="sex">
                    <el-select v-model="addForm.sex" placeholder="请选择">
                        <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
                    </el-select>
                </el-form-item>
                <el-form-item label="当前状态" prop="status">
                    <el-select v-model="addForm.status" placeholder="请选择">
                        <el-option v-for="item in optionss" :key="item.value" :label="item.label" :value="item.value" />
                    </el-select>
                </el-form-item>

                <el-form-item label="身份证号：" prop="idCard">
                    <el-col :span="11">
                        <el-input v-model="addForm.idCard" />
                    </el-col>
                </el-form-item>
                <el-form-item label="出身年月：" prop="birthday">
                    <el-col :span="11">
                        <el-date-picker v-model="addForm.birthday" type="date" placeholder="请选择出身年月" style="width: 100%" value-format="yyyy-MM-dd" />
                    </el-col>
                </el-form-item>
                <el-form-item label="家庭住址：" prop="address">
                    <el-col :span="11">
                        <el-input v-model="addForm.address" />
                    </el-col>
                </el-form-item>
                <el-form-item label="联系电话" prop="phone">
                    <el-col :span="11">
                        <el-input v-model="addForm.phone" />
                    </el-col>
                </el-form-item>
                <div class="listTop">
                    <div>家庭联系人：</div>
                    <!-- <el-button type="primary" size="mini">添加</el-button> -->
                </div>
                
                <el-button type="primary" icon="el-icon-plus" size="mini" @click="addColumn">新增</el-button>
                <el-table :data="bedList">
                    <el-table-column type="index" label="序号" />
                    <el-table-column label="名字" :show-overflow-tooltip="true" prop="name">
                        <template slot-scope="scope">
                            <el-input size="mini" placeholder="请输入内容" v-model="scope.row.name">
                            </el-input>
                        </template>
                    </el-table-column>

                    <el-table-column label="联系电话" prop="phone" :show-overflow-tooltip="true">
                        <template slot-scope="scope">
                            <el-input size="mini" placeholder="请输入内容" v-model="scope.row.phone">
                            </el-input>
                        </template>
                    </el-table-column>
                    <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
                        <template slot-scope="scope">
                            <el-button size="mini" type="text" icon="el-icon-delete" @click="deleteRow(scope.$index)">删除</el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <el-form-item label="护理等级：" prop="roomType" style="padding-top: 16px">
                    <el-col :span="11">
                        <el-select v-model="addForm.nursingGrade" placeholder="请选择护理等级">
                           <!-- <el-option label="介护" value="1" />
                            <el-option label="自理" value="2" />
                            <el-option label="非自理" value="3" /> -->
                             <el-option v-for="(item , index) in roomType" :key="index" :label="item.label" :value="item.value" />
                        </el-select>
                    </el-col>
                </el-form-item>
                <el-form-item label="入院时间：" prop="admissionTime">
                    <el-col :span="11">
                        <el-date-picker v-model="addForm.admissionTime" type="date" placeholder="请选择入院时间" style="width: 100%" value-format="yyyy-MM-dd" />
                    </el-col>
                </el-form-item>
                <!--<el-form-item label="当前床位：" prop="bedNumber">
                    <el-col :span="11">
                        <el-input v-model="addForm.bedNumber" placeholder="WS1564" :value="addForm.bedNumber" disabled />
                    </el-col>
                    </el-form-item>-->
                <el-form-item label="入住评估：" prop="roomType">
                    <el-col :span="11">
                        <el-select v-model="addForm.liveAssess" placeholder="请选择入住评估">
                          <!-- <el-option label="介护" value="1" />
                            <el-option label="自理" value="2" />
                            <el-option label="非自理" value="3" /> -->
                             <el-option v-for="(item , index) in roomType" :key="index" :label="item.label" :value="item.value" />
                        </el-select>
                    </el-col>
                </el-form-item>
                <el-form-item label="试住评估：" prop="occupancyAssess">
                    <el-col :span="11">
                        <el-select v-model="addForm.occupancyAssess" placeholder="请选择试住评估">
                          <!-- <el-option label="介护" value="1" />
                            <el-option label="自理" value="2" />
                            <el-option label="非自理" value="3" /> -->
                             <el-option v-for="(item , index) in roomType" :key="index" :label="item.label" :value="item.value" />
                        </el-select>
                    </el-col>
                </el-form-item>
                <el-form-item label="持续评估：" prop="roomType">
                    <el-col :span="11">
                        <el-select v-model="addForm.continuousAssess" placeholder="请选择持续评估：">
                           <!-- <el-option label="介护" value="1" />
                            <el-option label="自理" value="2" />
                            <el-option label="非自理" value="3" /> -->
                             <el-option v-for="(item , index) in roomType" :key="index" :label="item.label" :value="item.value" />
                        </el-select>
                    </el-col>
                </el-form-item>
                <!--<el-form-item label="密码">
                    <el-col :span="11">
                        <el-input v-model="addForm.passWord" />
                    </el-col>
                </el-form-item>-->
            </el-form>
        </div>

        <span slot="footer" class="dialog-footer">
            <el-button type="primary" @click="submitForm('addForm', 'add')">提交</el-button>
        </span>
    </el-dialog>

 <el-dialog title="" :visible.sync="showAddPopups" width="40%" center>
        <div class="scrollBox">
            <el-form ref="addForms" :model="addForms" :rules="rules" label-position="left" label-width="100px">
                <el-form-item label="姓名：" prop="name">
                    <el-col :span="11">
                        <el-input v-model="addForms.name" />
                    </el-col>
                </el-form-item>
                <el-form-item label="性别：" prop="sex">
                    <el-select v-model="addForms.sex" placeholder="请选择">
                        <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
                    </el-select>
                </el-form-item>
                <el-form-item label="当前状态" prop="status">
                    <el-select v-model="addForms.status" placeholder="请选择">
                        <el-option v-for="item in optionss" :key="item.value" :label="item.label" :value="item.value" />
                    </el-select>
                </el-form-item>

                <el-form-item label="身份证号：" prop="idCard">
                    <el-col :span="11">
                        <el-input v-model="addForms.idCard" />
                    </el-col>
                </el-form-item>
                <el-form-item label="出身年月：" prop="birthday">
                    <el-col :span="11">
                        <el-date-picker v-model="addForms.birthday" type="date" placeholder="请选择出身年月" style="width: 100%"  />
                    </el-col>
                </el-form-item>
                <el-form-item label="家庭住址：" prop="address">
                    <el-col :span="11">
                        <el-input v-model="addForms.address" />
                    </el-col>
                </el-form-item>
                <el-form-item label="联系电话" prop="phone">
                    <el-col :span="11">
                        <el-input v-model="addForms.phone" />
                    </el-col>
                </el-form-item>
                <div class="listTop">
                    <div>家庭联系人：</div>
                    <!-- <el-button type="primary" size="mini">添加</el-button> -->
                </div>
                
                <el-button type="primary" icon="el-icon-plus" size="mini" @click="addColumn">新增</el-button>
                <el-table :data="bedList">
                    <el-table-column type="index" label="序号" />
                    <el-table-column label="名字" :show-overflow-tooltip="true" prop="name">
                        <template slot-scope="scope">
                            <el-input size="mini" placeholder="请输入内容" v-model="scope.row.name">
                            </el-input>
                        </template>
                    </el-table-column>

                    <el-table-column label="联系电话" prop="phone" :show-overflow-tooltip="true">
                        <template slot-scope="scope">
                            <el-input size="mini" placeholder="请输入内容" v-model="scope.row.phone">
                            </el-input>
                        </template>
                    </el-table-column>
                    <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
                        <template slot-scope="scope">
                            <el-button size="mini" type="text" icon="el-icon-delete" @click="deleteRow(scope.$index)">删除</el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <el-form-item label="护理等级：" prop="roomType" style="padding-top: 16px">
                    <el-col :span="11">
                        <el-select v-model="addForms.nursingGrade" placeholder="请选择护理等级">
                           <!-- <el-option label="介护" value="1" />
                            <el-option label="自理" value="2" />
                            <el-option label="非自理" value="3" /> -->
                             <el-option v-for="(item , index) in roomType" :key="index" :label="item.label" :value="item.value" />
                        </el-select>
                    </el-col>
                </el-form-item>
                <el-form-item label="入院时间：" prop="admissionTime">
                    <el-col :span="11">
                        <el-date-picker v-model="addForms.admissionTime" type="date" placeholder="请选择入院时间" style="width: 100%"  />
                    </el-col>
                </el-form-item>
                <!--<el-form-item label="当前床位：" prop="bedNumber">
                    <el-col :span="11">
                        <el-input v-model="addForms.bedNumber" placeholder="WS1564" :value="addForms.bedNumber" disabled />
                    </el-col>
                    </el-form-item>-->
                <el-form-item label="入住评估：" prop="roomType">
                    <el-col :span="11">
                        <el-select v-model="addForms.liveAssess" placeholder="请选择入住评估">
                          <!-- <el-option label="介护" value="1" />
                            <el-option label="自理" value="2" />
                            <el-option label="非自理" value="3" /> -->
                             <el-option v-for="(item , index) in roomType" :key="index" :label="item.label" :value="item.value" />
                        </el-select>
                    </el-col>
                </el-form-item>
                <el-form-item label="试住评估：" prop="occupancyAssess">
                    <el-col :span="11">
                        <el-select v-model="addForms.occupancyAssess" placeholder="请选择试住评估">
                          <!-- <el-option label="介护" value="1" />
                            <el-option label="自理" value="2" />
                            <el-option label="非自理" value="3" /> -->
                             <el-option v-for="(item , index) in roomType" :key="index" :label="item.label" :value="item.value" />
                        </el-select>
                    </el-col>
                </el-form-item>
                <el-form-item label="持续评估：" prop="roomType">
                    <el-col :span="11">
                        <el-select v-model="addForms.continuousAssess" placeholder="请选择持续评估：">
                           <!-- <el-option label="介护" value="1" />
                            <el-option label="自理" value="2" />
                            <el-option label="非自理" value="3" /> -->
                             <el-option v-for="(item , index) in roomType" :key="index" :label="item.label" :value="item.value" />
                        </el-select>
                    </el-col>
                </el-form-item>
                <!--<el-form-item label="密码">
                    <el-col :span="11">
                        <el-input v-model="addForms.passWord" />
                    </el-col>
                </el-form-item>-->
            </el-form>
        </div>

        <span slot="footer" class="dialog-footer">
            <el-button type="primary" @click="submitForms">提交</el-button>
        </span>
    </el-dialog>







    <!-- 分配 -->
    <el-dialog title="" :visible.sync="showAllocationPopup" width="40%" center>
        <el-form ref="allocationForm" :model="allocationForm" :rules="rules" label-position="left" label-width="100px">
            <p>快速指派：（以下是当前全院空闲且可用的房间）</p>
            <div style="padding: 12px 0">
                <el-radio-group v-model="allocationForm.room">
                    <el-radio v-for="(item, index) in roomList" :key="index" :label="item.name" name="type" />
                </el-radio-group>
            </div>
            <el-form-item label="搜索空闲床位：" prop="search" size="mini" label-width="110px">
                <el-col :span="12" style="padding-right: 18px">
                    <el-input v-model="allocationForm.search" :span="12" />
                </el-col>
                <el-button type="primary" size="mini">搜索</el-button>
            </el-form-item>
            <div>确认床位参数：{{ allocationForm.search }}</div>
            <div class="submitBox">
                <el-button type="primary" size="mini" @click="onSubmit('allocationForm')">确认分配</el-button>
            </div>
        </el-form>
    </el-dialog>
    <!-- 列表 -->
    <el-table ref="multipleTable" height="700px" :data="tableData" :header-cell-style="{ background: '#efefef' }" tooltip-effect="dark" style="width: 100%" @selection-change="select">
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column prop="name" label="姓名" align="center" />
        <el-table-column prop="sex" label="性别" align="center">
            <template slot-scope="scope">
                {{scope.row.sex==0?'男':'女'}}
            </template>
        </el-table-column>
        <el-table-column prop="idCard" label="身份证号" align="center" />
        <el-table-column prop="phone" label="账号" align="center" />
        <el-table-column prop="bedName" label="入住床位号" align="center" />
        <el-table-column prop="status" label="状态" align="center">
            <template slot-scope="scope">
                {{scope.row.status==0?'在院':'请假'}}
            </template>
        </el-table-column>
        <el-table-column fixed="right" label="操作" width="220" align="center">
            <template slot-scope="scope">
                <el-button type="text" size="small" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
                <el-button type="text" style="color: #f56c6c" size="small" @click="handleDelete(scope.$index, scope.row)">移除</el-button>
            </template>
        </el-table-column>
    </el-table>
    <el-pagination class="controlBox" style="margin-top: 20px" background :current-page="currentPage" :page-sizes="[5, 10, 20, 40]" :page-size="pageSize" layout="total,sizes, prev, pager, next, jumper" :total="total" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
</div>
</template>

<script>
import {
    delElderId,
    renew,
    renewal,
    getPaging,
    getfindById,
    updaterenewal
} from "../../../../api/user.js";
export default {
    components: {},
    data() {
        return {
            showAddPopup: false,
            showAddPopups: false,
            showAllocationPopup: false,
            currentPage: 1, //  初始页currentPage
            pageSize: 10, //  每页的数据
            number: "", // 点击删除的数组
            total: 0, //总条数
            // 床位表格数据
            bedList: [],
            bedLists: [],
            elder:'',//点击编辑获取的信息
            search: {
                id: "",
            },
            roomType:[
                {label:'介助',value:0},
                {label:'介护',value:1},
                {label:'特A',value:2},
            ],
            addForm: {
                name: "", // 姓名
                sex: "", // 性别
                status: "", // 状态
                idCard: "", // 身份证号
                birthday: "", // 生日
                address: "", // 家庭住址
                phone: "", // 联系电话
                nursingGrade: "", // 护理等级
                admissionTime: "", // 入院时间
                bedNumber: "", // 当前床位
                liveAssess: "", // 入住评估
                occupancyAssess: "", // 试住评估
                continuousAssess: "", // 持续评估
                passWord: "", // 密码
              
            },
            addForms: {
                name: "", // 姓名
                sex: "", // 性别
                status: "", // 状态
                idCard: "", // 身份证号
                birthday: "", // 生日
                address: "", // 家庭住址
                phone: "", // 联系电话
                nursingGrade: "", // 护理等级
                admissionTime: "", // 入院时间
                bedNumber: "", // 当前床位
                liveAssess: "", // 入住评估
                occupancyAssess: "", // 试住评估
                continuousAssess: "", // 持续评估
                passWord: "", // 密码
              
            },
            allocationForm: {
                room: "",
                search: "",
            },
            options: [{
                    value: 0,
                    label: "男",
                },
                {
                    value: 1,
                    label: "女",
                },
            ],
            optionss: [{
                    value: 0,
                    label: "在院",
                },
                {
                    value: 1,
                    label: "请假",
                },
            ],
            roomList: [{
                    id: 1,
                    name: "WS101A",
                },
                {
                    id: 2,
                    name: "WS102B",
                },
                {
                    id: 3,
                    name: "WS1022",
                },
            ],
            redactFormIndex: "",
            tableData: [],
            linkManList: [],
            rules: {
                name: [{
                    required: true,
                    message: "请填写姓名",
                    trigger: "blur",
                }, ],
                sex: [{
                    required: true,
                    message: "请填写性别",
                    trigger: "blur",
                }, ],
                state: [{
                    required: true,
                    message: "请选择状态",
                    trigger: "change",
                }, ],
                IDnumber: [{
                        required: true,
                        message: "请填写身份证号码",
                        trigger: "blur",
                    },
                    {
                        required: true,
                        pattern: "^[1-9]\\d{5}(18|19|20|(3\\d))\\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$",
                        message: "请填写正确的身份证号码",
                        trigger: "blur",
                    },
                ],
                birthday: [{
                    required: true,
                    message: "请选择出生年月",
                    trigger: "change",
                }, ],
                familyAddress: [{
                    required: true,
                    message: "请填写家庭住址",
                    trigger: "blur",
                }, ],
                linkPhone: [{
                        required: true,
                        message: "请输入联系电话",
                        trigger: "blur",
                    },
                    {
                        required: true,
                        pattern: "^1[3456789]\\d{9}$",
                        message: "请输入正确的联系电话",
                        trigger: "blur",
                    },
                ],
                accountNumber: [{
                        required: true,
                        message: "请输入账号",
                        trigger: "blur",
                    },
                    {
                        required: true,
                        pattern: "^[0-9]{2}$",
                        message: "请输入正确的账号，账号位2位数字",
                        trigger: "blur",
                    },
                ],
                admissionTime: [{
                    required: true,
                    message: "请填写入院时间",
                    trigger: "blur",
                }, ],
                nursingGrade: [{
                    required: true,
                    message: "请选择护理等级",
                    trigger: "change",
                }, ],
                liveAssess: [{
                    required: true,
                    message: "请选择入住评估",
                    trigger: "change",
                }, ],
                occupancyAssess: [{
                    required: true,
                    message: "请选择试住评估",
                    trigger: "change",
                }, ],
                continuousAssess: [{
                    required: true,
                    message: "请选择持续评估",
                    trigger: "change",
                }, ],
                passWord: [{
                        required: true,
                        message: "请输密码",
                        trigger: "blur",
                    },
                    {
                        required: true,
                        pattern: "^[A-Za-z0-9]{6,8}$",
                        message: "密码为6~8位数字和字母",
                        trigger: "blur",
                    },
                ],
            },
        };
    },
    computed: {},
    watch: {},
    created() {
        this.findSexList();
    },
    mounted() {
        this.sybase();
    },
    updated() {}, // 生命周期 - 更新之后
    beforeDestroy() {}, // 生命周期 - 销毁之前
    destroyed() {}, // 生命周期 - 销毁完成
    activated() {},
    methods: {

        submitForms(){
            console.log(this.bedList);
            updaterenewal(
            this.addForms.id, // 姓名
            this.addForms.name, // 姓名
            this.addForms.sex, // 性别
            this.addForms.status, // 状态
            this.addForms.birthday, // 生日
            this.addForms.idCard, // 身份证号
            this.addForms.address, // 家庭住址
            this.addForms.phone, // 联系电话
            this.addForms.nursingGrade, // 护理等级
            this.addForms.admissionTime, // 入院时间
            this.addForms.liveAssess, // 入住评估
            this.addForms.occupancyAssess, // 试住评估
            this.addForms.continuousAssess, // 持续评估
            this.bedList        
                  //联系人
             ).then((res) => {
                if(res.code==2000){
                     this.showAddPopups = false;
                      this.sybase();
                this.$message({
                type: 'success',
                message: '修改成功!'
                });
                }
            }).catch((err) => {
          console.log(this.addForms);  
             })
        },







        addAccount() {
            this.showAddPopup = true;
            this.addForm = {
                name: "", // 姓名
                sex: "", // 性别
                status: "", // 状态
                idCard: "", // 身份证号
                birthday: "", // 生日
                address: "", // 家庭住址
                phone: "", // 联系电话
                nursingGrade: "", // 护理等级
                admissionTime: "", // 入院时间
                bedNumber: "", // 当前床位
                liveAssess: "", // 入住评估
                occupancyAssess: "", // 试住评估
                continuousAssess: "", // 持续评估
                passWord: "", // 密码
            };
        },
        addColumn() {
            let aa = {
                "name": "",
                "phone": '',
            }
            this.bedList.push(aa)
          
        },
        deleteRow(index) {
            console.log(this.bedList)
            this.bedList.splice(index, 1)
        },
        // 编辑和新增老人
        submitForm(formName, tag) {
            this.$refs[formName].validate((valid) => {
                if (valid) {
                    if (tag == "add") {
                        renewal(
                                this.addForm.name, // 姓名
                                this.addForm.sex, // 性别
                                this.addForm.status, // 状态
                                this.addForm.birthday, // 生日
                                this.addForm.idCard, // 身份证号
                                this.addForm.address, // 家庭住址
                                this.addForm.phone, // 联系电话
                                this.addForm.nursingGrade, // 护理等级
                                this.addForm.admissionTime, // 入院时间
                                this.addForm.liveAssess, // 入住评估
                                this.addForm.occupancyAssess, // 试住评估
                                this.addForm.continuousAssess, // 持续评估
                                this.bedList //联系人
                            )
                            .then((res) => {
                                console.log(res);
                                this.showAddPopup = false;
                                // this.deleteRow()
                                this.sybase();
                                this.$message({
                                    type: "success",
                                    message: "新增成功!",
                                });
                            })
                            .catch((err) => {
                                console.log(err);
                            });
                    } else if (tag == "addForm") {
                          console.log(132);
                        this.tableData[this.redactFormIndex] = this.addForm;
                             console.log(this.tableData[this.redactFormIndex]);
                        
               
                    }

                } else {
                    this.$message("error submit!!");
                    return false;
                }
            });
        },
        onSubmit(formName) {
            this.$refs[formName].validate((valid) => {
                if (valid) {
                    this.$message("submit!");
                } else {
                    this.$message("error submit!!");
                    return false;
                }
            });
        },
        // 新增 编辑
        handleEdit(index, row) {
            this.showAddPopups = true;
            this.addForms = row;
            this.redactFormIndex = index;
            // console.log(index, row);
            getfindById(
                row.id
            ).then((res) =>{
                if(res.code==2000){
                    console.log(res);
                    this.addForms=res.data.elder
                    this.addForms.birthday=this.addForms.birthday.slice(0,10)
                    this.addForms.admissionTime=this.addForms.admissionTime.slice(0,10)
                res.data.elder.contacts.map(res_1=>{
                    this.bedList.push({id:res_1.id,name:res_1.name,phone:res_1.phone})
                })
                console.log(this.bedList)

                }
            }).catch((err) =>{
              console.log(err);  
            })
        },
        // 分配
        allocationPopup(index, row) {
            this.showAllocationPopup = true;
            console.log(index, row);
        },
        // 移除老人
        handleDelete(index, row) {
            // console.log(index, row)
            this.$confirm("此操作将永久删除项, 是否继续?", "提示", {
                    confirmButtonText: "确定",
                    cancelButtonText: "取消",
                    type: "warning",
                })
                .then(() => {
                    delElderId(row.id)
                        .then((res) => {
                            this.tableData.splice(index, 1);
                            this.$message({
                                type: "success",
                                message: "删除成功!",
                            });
                        })
                        .catch((err) => {
                            this.$message({
                                type: "info",
                                message: "删除失败",
                            });
                        });
                })
                .catch(() => {
                    this.$message({
                        type: "info",
                        message: "已取消删除",
                    });
                });
        },
        async findSexList() {},
        async insertEvent(row) {
            let record = {
                sex: "1",
            };
            let {
                row: newRow
            } = await this.$refs.xTable.insertAt(record, row);
            await this.$refs.xTable.setActiveCell(newRow, "name");
        },
        //保存按钮
        saveEvent() {
            const {
                insertRecords,
                removeRecords,
                updateRecords,
            } = this.$refs.xTable.getRecordset();
            this.linkManList = this.$refs.xTable.editStore.insertList;
            console.log(this.linkManList);
        },

        //删除联系人
        removeEvent(row) {
            this.$refs.xTable.remove(row);
        },
        // 初始页currentPage、初始每页数据数pageSize和数据data
        handleSizeChange: function (size) {
            this.pageSize = 1;
            this.pageSize = size;
            this.sybase();
            console.log(this.pageSize); // 每页下拉显示数据
        },
        handleCurrentChange: function (currentPage) {
            this.currentPage = currentPage;
            this.sybase();
            console.log(this.currentPage); // 点击第几页
        },
        //多选删除
        select(select, row) {
            this.number = [];
            select.map((item) => {
                this.number.push(item.id);
            });
            console.log(this.number);
        },
        //获取老人列表
        sybase() {
            getPaging(this.currentPage, this.pageSize)
                .then((res) => {
                    // console.log(res);
                    this.tableData = res.data.elders;
                    this.total = res.data.total;
                    // console.log(this.tableData);
                })
                .catch((err) => {
                    console.log(err);
                });
        },
        // 根据老人id进行搜索
        getDictListFun() {
            getfindById(this.search.id).then((res) => {
                if (res.data.elder == null) {
                    this.tableData = [];
                } else {
                    console.log(res);
                    this.tableData = [];
                    this.tableData.push(res.data.elder);
                }
            });
        },
        // //删除老人
        // deletes() {
        // 	if (this.number.length == 0) {
        // 		this.$message.error('至少选中一条数据')
        // 		return
        // 	}
        // 	this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
        // 		confirmButtonText: '确定',
        // 		cancelButtonText: '取消',
        // 		type: 'warning'
        // 	}).then(() => {
        // 		delElderId(
        // 		this.number.
        // 		).then((res) => {
        // 		console.log(res);
        // 		this.$message({
        // 		type: 'success',
        // 		message: '删除成功!'
        // 		});
        // 		}).catch((err) => {
        // 		this.$message({
        // 		type: "info",
        // 		message: "删除失败"
        // 		});
        // 		})
        // 	}).catch(() => {
        // 		this.$message({
        // 		type: 'info',
        // 		message: '已取消删除'
        // 		});
        // 	});
        // }
    },
};
</script>

<style lang="scss" scoped>
.container {
    padding: 20px;

    .controlBox {
        padding-bottom: 16px;
    }

    .scrollBox {
        height: 600px;
        overflow: auto;
    }

    .scrollBox::-webkit-scrollbar {
        display: none;
    }

    .listTop {
        font-size: 16px;
        color: #666;
        display: flex;
        justify-content: space-between;
        padding-bottom: 10px;
    }

    .submitBox {
        padding: 14px 0;
        display: flex;
        justify-content: center;
    }
}
</style>
